package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.ReplyDTO;
import com.tianji.learning.domain.query.ReplyPageQuery;
import com.tianji.learning.domain.vo.ReplyVO;
import com.tianji.learning.service.IInteractionReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 管理端互动问题的回答或评论 前端控制器
 * </p>
 *
 * @author huanghui
 * @since 2023-07-25
 */
@RestController
@RequestMapping("/admin/replies")
@RequiredArgsConstructor
@Api(tags = "管理端互动互答相关接口")
public class InteractionReplyAdminController {

    private final IInteractionReplyService replyService;

    /** @author ZXX-挚爱
    * @Description 隐藏或显示评论
    * @Dete 10:25 2023/7/27
    * @Param [id, hidden]
    * @return void
    **/

    @ApiOperation("隐藏或显示评论")
    @PutMapping("/{id}/hidden/{hidden}")
    public void hiddenReply(
            @ApiParam(value = "问题id", example = "1684484733357309953") @PathVariable("id") Long id,
            @ApiParam(value = "是否隐藏，true/false", example = "true") @PathVariable("hidden") Boolean hidden
    ){
        replyService.hiddenReply(id, hidden);
    }

   /** @author ZXX-挚爱
   * @Description 分页查询回答或评论
   * @Dete 10:25 2023/7/27
   * @Param [pageQuery]
   * @return com.tianji.common.domain.dto.PageDTO<com.tianji.learning.domain.vo.ReplyVO>
   **/

    @ApiOperation("管理端分页查询回答或评论")
    @GetMapping("page")
    public PageDTO<ReplyVO> queryReplyPage(ReplyPageQuery pageQuery){
        return replyService.queryReplyPage(pageQuery, true);
    }

    /** @author ZXX-挚爱
    * @Description 根据id查询回答或评论
    * @Dete 10:25 2023/7/27
    * @Param [id]
    * @return com.tianji.learning.domain.vo.ReplyVO
    **/

    @ApiOperation("根据id查询回答或评论")
    @GetMapping("{id}")
    public ReplyVO queryReplyById(
            @ApiParam(value = "问题id", example = "1") @PathVariable("id") Long id){
        return replyService.queryReplyById(id);
    }
}
